﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hands.FileCache
{
    internal class MemoryCache : Cache, ICache
    {
        private Dictionary<string, File> fileSet = new Dictionary<string, File>();

        internal MemoryCache()
            : base()
        {

        }

        protected override void addFileToCache(File file)
        {
            if (!fileSet.ContainsKey(file.FileName))
            {
                fileSet.Add(file.FileName, file);
            }
        }



        #region ICache 成员

        public File find(string fileName)
        {
            if (fileSet.ContainsKey(fileName))
            {
                return fileSet[fileName];
            }
            else
            {
                throw new FileNotConfigException(fileName + "没有找到");
            }
        }

        #endregion
    }
}
